<?php
/**
 * Created by PhpStorm.
 * User: huynguyen
 * Date: 9/23/14
 * Time: 9:15 PM
 */

namespace Backend\Modules\Upload\Controllers;
use Library\Upload\UploadHandler;

class UploadController extends \BackendController
{
    public function indexAction()
    {
        if($this->request->isPost())
        {
            //die(print_r($this->request->getUploadedFiles()));
            $uploadHandler = new UploadHandler($option = array('param_name' => 'file'));
            die(print_r($uploadHandler));
        }

        if ($this->request->isAjax())
        {
            $uploadHandler = new UploadHandler($option = array('param_name' => 'file'));
            die(print_r($uploadHandler));

            //$uploadHandler->post();
            //die(print_r($this->request->getPost()));
            //$image = $this->request->getPost('file');
            /*foreach ($this->request->getUploadedFiles() as $file) {

                //Print file details
                echo $file->getName(), " ", $file->getSize(), "\n";

                //Move the file into the application
                $file->moveTo('files/' . $file->getName());
            }*/
            return json_encode($uploadHandler);
        }
    }
}